package controllers.bluehat.backbone;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import models.Focus;
import models.InformationUnit;
import models.User;
import utils.json.data.AbstractJson;
import utils.json.data.backbone.FocusJson;
import utils.json.data.backbone.InfoUnitJson;
import utils.json.data.backbone.UserJson;
import controllers.BaseController;

public class UserController extends BaseController {

	public static void summary(Long userId) {
		if(userId == null) error();
		
		User user = User.findById(userId);
		
		renderJSON(new UserJson(user));
	}
	
	public static void infounits(Long userId) {
		if(userId == null) error();
		
		User user = User.findById(userId);
		
		List<InfoUnitJson> unitsJson = new ArrayList<InfoUnitJson>();
		for(InformationUnit unit : user.informations.fetch()) {
			unitsJson.add(new InfoUnitJson(unit));
		}
		
		renderJSON(unitsJson);
	}
}
